package com.gxa.controller.commserve;

import com.gxa.common.utils.Result;
import com.gxa.entity.commserve.RecruitmentRecord;
import com.gxa.service.commserve.RecruitmentRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:00
 */
@Api(tags = "失物招领记录")
@RestController
@RequestMapping("/recruitment-record")
public class RecruitmentRecordController {
    @Autowired
    private RecruitmentRecordService recruitmentRecordService;


//    Date date = new Date("2022/10/11");
//    List<Object> recruitmentRecordList;
//    public RecruitmentRecordController(){this.init();}
//    void init(){
//        recruitmentRecordList = new ArrayList<>();
//        LostFound lostFound = new LostFound(1,"zs","sadfss",date,date,"李四","12345678910","成都",0,0);
//        RecruitmentRecord recruitmentRecord = new RecruitmentRecord(1,"发布招领","张三丰",date,lostFound,0);
//        recruitmentRecordList.add(recruitmentRecord);
//        LostFound lostFound1= new LostFound(2,"zs","sadfss",date,date,"李四","12345678910","成都",0,0);
//        RecruitmentRecord recruitmentRecord1 = new RecruitmentRecord(2,"发布招领","张三丰",date,lostFound,0);
//        recruitmentRecordList.add(recruitmentRecord1);
//    }

    @CrossOrigin(origins = "*",maxAge = 3600)//跨域请求配置
    @ApiOperation(value = "查询失物招领记录")
    @GetMapping("list/{id}")
    public Result list(@PathVariable("id") Integer id){
        try {
            List<RecruitmentRecord> recruitmentRecordList = this.recruitmentRecordService.queryList(id);
            Result<List<RecruitmentRecord>> result = Result.success(recruitmentRecordList);
            return result;
        }catch (Exception e){
            return Result.failed("查询失败"); }
    }




}
